import { Command } from "commander"
import { ArkLeakAnalyzer, ILoggable } from "@meminsight/core";
import { IProcess } from "./IProcess";
import { Version } from "../Version";

/**
 * Ark Leak Process
 */
export class ArkLeakProc implements IProcess, ILoggable {
    public readonly DOMAIN: string = 'meminsight';
    public readonly TAG: string = ArkLeakProc.name;
    public static readonly CMD: string = "ark-leak";
    public static readonly DESC: string = "ark leaks analysis process.";
    public static readonly VER: string = Version.ARK_LEAK.toString();
    private static _instance: ArkLeakProc;

    private _analyzer: ArkLeakAnalyzer;

    /**
     * get instance
     * @returns instance
     */
    public static instance(): ArkLeakProc {
        if (!ArkLeakProc._instance) {
            ArkLeakProc._instance = new ArkLeakProc();
        }
        return ArkLeakProc._instance;
    }

    public initialize(proc: Command, any: any) {
        this._analyzer = any as ArkLeakAnalyzer;
        proc.command(ArkLeakProc.CMD)
            .description(ArkLeakProc.DESC)
            .option("-1, --from <from heapsnapshot>", "from-scenario heapsnapshot file")
            .option("-2, --to <file>", "to-scenario heapsnapshot file")
            .option("-3, --target <file>", "target heapsnapshot file")
            .option("-o, --output <file>", "output file")
            .option("-f, --output_file <file type>", "output file type, console | text | json | html.")
            .action(async (options) => {
                // TODO
            });
    }

    private async process(args: Map<string, any>): Promise<void> {
        // TODO:         
    } 
}